class Stack:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return  self.items == []

    def push(self,item):
        self.items.append(item)

    def pop(self):
        return self.items.pop()

    def peek(self):
        return self.items[len(self.items)-1]

    def size(self):
        return len(self.items)

def fuhao_match(left,right):
    a="({["
    b=")}]"
    return a.index(left) == b.index(right)


def parcheck(kuohao):
    s = Stack()
    balanced = True
    index = 0
    while index < len(kuohao) and balanced:
        fuhao = kuohao[index]
        if fuhao  in  "({[":
            s.push(fuhao)
        else:
            if s.isEmpty():
                balanced = False
            else:
                fuhao_pop=s.pop()
                if not fuhao_match(fuhao_pop,fuhao):
                    balanced = False
        index = index +1

    if balanced and s.isEmpty():
        return True
    else:
        return  False


print(parcheck("(([]{}))"))